<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN>
<html lang = "en">
<head>
  <title>Visige</title>
  <% if cookies[:colour_scheme].nil? %>
  	<% cookies[:colour_scheme] = 0 %>
  <% end %>
  <% colour_scheme = cookies[:colour_scheme].to_i %>
  <% if colour_scheme == 1 %>  	
  	<%= stylesheet_link_tag "colour_scheme_bow" %>
  <% elsif colour_scheme == 0 %>
  	<%= stylesheet_link_tag "colour_scheme_wob" %>
  <% end %>
  <%= stylesheet_link_tag "scaffold" %>
  <%= stylesheet_link_tag "splash" %>  
  <%= javascript_include_tag :defaults %>
  <%= csrf_meta_tag %>
  <script type="text/javascript">
	  var _gaq = _gaq || [];
	  _gaq.push(['_setAccount', 'UA-26152447-1']);
	  _gaq.push(['_trackPageview']);

	  (function() {
		var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
		ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
		var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
	  })();
	</script>
	
</head>
<body>

<div id="page_container">
	<div class="page_header">
		<div id="logo_container">
			<h1 style="display:inline"><%= link_to "Welcome to VISIGE!", root_url, :id => "logo_link" %></h1>
			<% if flash[:alert] %>
				<p id="notice" style="float:right" ><%= flash[:alert] %></p>
			<% end %>
		</div>
		

		<% if (session[:user_id].nil?) %>
			
			<% unless request.fullpath == "/entities/new" %>
				<div id="user_nav">				
					<%= form_tag(:controller => "sessions", :action => "create", :method => "post") do %>				
						<label for="email" >Email:</label>
						<%= text_field_tag :email, params[:email], :title => "Email Address"  %>				
						<label for="password" >Password:</label>
						<%= password_field_tag :password, params[:password], :title => "Enter Password"  %>				
						<%= submit_tag "Login", :title => "Click here to log in", :class => "submit_login" %>
					<% end %>
					<p>New User? <%= link_to 'Sign up', new_entity_path %></p>
					<div id="wrapper"></div>		
				</div>	
			<% else %>
				<div id="user_pad"></div>
			<% end %>
					
		<% else %>
			<div id="user_nav">
				<% @current_user = Entity.find(session[:user_id]) %>
				<ul>
					<li>Welcome <%= link_to @current_user.name, entity_path(@current_user), :class => "entity_link", :accesskey=>"1" %></li>
					<li><%= link_to 'Logout', logout_path,:style => "color:gold" %></li>
				</ul>
				</br>
			</div>				
		<% end %>
		
		<div id="logged_in_actions">
			<% if !(session[:user_id].nil?) %>
				<% @entity = Entity.find(session[:user_id]) %>
				<% c = Friendship.find_all_by_friend_id_and_accepted(@entity.id, false).count %>
				<% m = @entity.new_messages.count %>
				<% t = m + c %>
				<ul>
					<li><%= link_to "Catch me up! (" + t.to_s + " new)", recent_activity_path(session[:user_id]) %></li>
					<li><%= link_to "Search for friends!", entities_path %></li>
					<li><%= link_to "View public feed", feed_path(session[:user_id]) %></li>
					<li><%= link_to "View your profile", entity_path(session[:user_id]) %></li>
					<li><%= link_to "Account settings", edit_entity_path(session[:user_id]) %></li>
					<li><%= link_to "Display Settings", css_settings_form_path(session[:user_id]) %></li>
				</ul>
			<% end %>
		</div>
		<div id="wrapper"></div>
	</div>	
	<div class="page_content">
	<%= yield %>
	<div id="wrapper"></div>
	</div>	
</div>
<script type="text/javascript" src="http://mediaplayer.yahoo.com/js"></script>
</body>
</html>
